package com.meichis.yndms.room.dao;


import androidx.room.*;

import com.meichis.yndms.model.VisitTemplate;

import java.util.List;

import io.reactivex.Flowable;

@Dao
public interface VisitTemplateDao {
    @Query("SELECT * FROM VisitTemplate")
    Flowable<List<VisitTemplate>> findAll();

    @Query("SELECT * FROM VisitTemplate")
    List<VisitTemplate> find();

    @Query("SELECT * FROM VisitTemplate WHERE ID=:id")
    VisitTemplate find(int id);

    @Query("SELECT Code FROM VisitTemplate WHERE ID in (:id)")
    String[] findCode(int[] id);

    @Query("SELECT * FROM VisitTemplate WHERE OwnerClient=:ownerClient")
    List<VisitTemplate> findByOwnerClient(int ownerClient);

    @Query("DELETE FROM VisitTemplate")
    int deleteAll();

    @Query("DELETE FROM VisitTemplate WHERE ID=:id")
    int delete(int id);

    @Delete
    int delete(VisitTemplate... VisitTemplates);

    @Update
    int update(VisitTemplate... VisitTemplates);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insert(List<VisitTemplate> list);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insert(VisitTemplate... VisitTemplates);

    @Query("SELECT * FROM VisitTemplate WHERE Code=:code")
    VisitTemplate findByCode(String code);

    @Query("SELECT * FROM VisitTemplate WHERE Code IN(:params2)")
    List<VisitTemplate> findTemplateByParams(List<String> params2);
}

